package com.xuyuan.arithmetic.datastructure.quest;

/**
 * 示例代码：数字加密
 */
public class NumberEncryptor {
    // 加密方法，将每个数字加上3进行替换
    public static String encrypt(int number) {
        String numberStr = String.valueOf(number);
        StringBuilder encrypted = new StringBuilder();

        for (char digit : numberStr.toCharArray()) {
            int digitValue = Character.getNumericValue(digit);
            int encryptedDigit = (digitValue + 3) % 10; // 确保结果在0-9之间
            encrypted.append(encryptedDigit);
        }

        return encrypted.toString();
    }

    public static void main(String[] args) {
        int randomNumber = 1234; // 示例随机4位数
        String encryptedNumber = encrypt(randomNumber);
        System.out.println("原始数字: " + randomNumber);
        System.out.println("加密结果: " + encryptedNumber);
    }
}
